<div id="main_content" class="addEmoloyee">
    <h3 class="m10"><?php echo $title; ?></h3>
    <a href="<?php echo base_url(); ?>employee" class="btn addEmoloyeeBack m10"><?php echo $back; ?></a>
    <div class="form_add addEmoloyee">  
        <form action="" method="post">
            <table border="0" class="add_data">
                <tr>
                    <td align="right" class="tbl_col_left">
                        <label><?php echo $employeeName; ?> <font color="#FF0000">(*)</font></label>
                    </td>
                    <td>
                        <input type="hidden" name="txtEmployeeId" class="txtEmployeeId" value="<?php echo $id; ?>">
                        <input type="text" name="txtEmployeeName" class="txtEmployeeName" size="50" value="<?php echo $txtEmployeeName; ?>">
                        <span class="error"><?php echo form_error('txtEmployeeName'); ?></span>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label><?php echo $dateOfBirth; ?> <!--<font color="#FF0000">(*)</font>--></label>
                    </td>
                    <td>
                        <input type="text" name="txtDateOfBirth" size="10" maxlength="10" class="datepicker" value="<?php echo $txtDateOfBirth; ?>">
                        <i>(<?php echo $this->lang->line('formatDay'); ?>)</i>
                        <span class="error"><?php echo form_error('txtDateOfBirth'); ?></span>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label><?php echo $joinDate; ?> <font color="#FF0000">(*)</font></label>
                    </td>
                    <td>
                        <div class="colLeft">
                            <input type="text" name="txtJoinDate" size="10" maxlength="10" class="datepicker" value="<?php echo $txtJoinDate; ?>">
                            <i>(<?php echo $this->lang->line('formatDay'); ?>)</i>
                            <div class="error"><?php echo form_error('txtJoinDate'); ?></div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label><?php echo $email; ?> </label>
                    </td>
                    <td>
                        <div class="colLeft">
                            <input type="text" name="txtEmail" size="30" maxlength="255" class="txtEmail" value="<?php echo $txtEmail; ?>">
                            <div class="error"><?php echo form_error('txtEmail'); ?></div>
                        </div>
                        <div class="colRight">
                            <label>&nbsp;&nbsp; <?php echo $phone; ?> &nbsp;&nbsp;</label>
                            <input type="text" name="txtPhone" size="20" maxlength="50" class="txtPhone" value="<?php echo $txtPhone; ?>">
                            <div class="error"><?php echo form_error('txtPhone'); ?></div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label><?php echo $position; ?> <!--<font color="#FF0000">(*)</font>--></label></label>
                    </td>
                    <td>
                        <select name="cmbPosition" class="cmbPosition">
                            <option value=""><?php echo $nullcharacter; ?></option>
                            <?php if (count($employeePositionList)): ?>
                                <?php foreach ($employeePositionList as $item): ?>
                                    <option value="<?php echo $item->PositionId; ?>" <?php echo($cmbPosition == $item->PositionId) ? 'selected' : ''; ?>><?php echo dQuotes($item->PositionName); ?></option>
                                <?php endforeach; ?>
                            <?php endif; ?>
                        </select>
                        <span class="error"><?php echo form_error('cmbPosition'); ?></span>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label><?php echo $cardID; ?> <font color="#FF0000">(*)</font></label>
                    </td>
                    <td>
                        <input type="text" name="txtidCardNumber" size="50" class="txtidCardNumber" maxlength="255" value="<?php echo $txtidCardNumber; ?>">
                        <span class="error"><?php echo form_error('txtidCardNumber'); ?></span>
                    </td>
                </tr> 
                <tr>
                    <td align="right">
                        <label><?php echo $address1; ?> </label>
                    </td>
                    <td>
                        <input type="text" name="txtContactAddressLine1" size="50" maxlength="255" value="<?php echo $txtContactAddressLine1; ?>">
                        <span class="error"><?php echo form_error('txtContactAddressLine1'); ?></span>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label><?php echo $address2; ?> </label>
                    </td>
                    <td>
                        <input type="text" name="txtContactAddreddLine2" size="50" maxlength="255" value="<?php echo $txtContactAddreddLine2; ?>">
                        <span class="error"><?php echo form_error('txtContactAddreddLine2'); ?></span>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label><?php echo $employeeType; ?> <font color="#FF0000">(*)</font></label>
                    </td>
                    <td>
                        <select name="cmbEmployeeType" class="cmbEmployeeType">
                            <option value=""><?php echo $nullcharacter; ?></option>
                            <?php if (count($employeeTypeList)): ?>
                                <?php foreach ($employeeTypeList as $key => $value): ?>
                                    <?php if ($key !== ''): ?>
                                        <option value="<?php echo $key; ?>" <?php echo($cmbEmployeeType == $key && $cmbEmployeeType !== '') ? 'selected' : ''; ?>><?php echo $value; ?></option>
                                    <?php endif; ?>
                                <?php endforeach; ?>
                            <?php endif; ?>
                        </select>
                        <span class="error"><?php echo form_error('cmbEmployeeType'); ?></span>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label class="lblEmployeeDate"><?php echo $startProbationaryDate; ?> <font color="#FF0000">(*)</font></label>
                    </td>
                    <td>
                        <div class="colLeft">
                            <input type="text" name="txtStartProbationaryDate" size="10" maxlength="10" class="datepicker txtStartProbationaryDate" value="<?php echo $txtStartProbationaryDate; ?>">
                            <i>(<?php echo $this->lang->line('formatDay'); ?>)</i>
                            <div class="error"><?php echo form_error('txtStartProbationaryDate'); ?></div>
                        </div>
                        <div class="colRight">
                            <label class="lblEmployeeDate" style="float:left;">&nbsp;&nbsp; <?php echo $endProbationaryDate; ?> <font color="#FF0000">(*)</font>&nbsp;&nbsp;</label>
                            <input type="text" name="txtEndProbationaryDate" size="10" maxlength="10" class="datepicker txtEndProbationaryDate" value="<?php echo $txtEndProbationaryDate; ?>">
                            <i>(<?php echo $this->lang->line('formatDay'); ?>)</i>
                            <div class="error"><?php echo form_error('txtEndProbationaryDate'); ?></div>
                        </div>
                        <div class="clr"></div>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label class="lblEmployeeDate StartOfficialDate"><?php echo $startOfficialDate; ?> <font color="#FF0000">(*)</font></label>
                    </td>
                    <td>
                        <div class="colLeft">
                            <input type="text" name="txtStartOfficialDate" size="10" maxlength="10" class="datepicker txtStartOfficialDate" value="<?php echo $txtStartOfficialDate; ?>">
                            <i>(<?php echo $this->lang->line('formatDay'); ?>)</i>
                            <div class="error"><?php echo form_error('txtStartOfficialDate'); ?></div>
                        </div>
                        <div class="colRight">
                            <label class="lblEmployeeDate EndOfficialDate" style="float:left;">&nbsp;&nbsp; <?php echo $endOfficialDate; ?> <font color="#FF0000">(*)</font>&nbsp;&nbsp;</label>
                            <input type="text" name="txtEndOfficialDate" size="10" maxlength="10" class="datepicker txtEndOfficialDate" value="<?php echo $txtEndOfficialDate; ?>">
                            <i>(<?php echo $this->lang->line('formatDay'); ?>)</i>
                            <div class="error"><?php echo form_error('txtEndOfficialDate'); ?></div>
                        </div>
                        <div class="clr"></div>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label><?php echo $status; ?></label>
                    </td>
                    <td>
                        <input type="checkbox" name="cmbStatus" class="cmbStatus" value="1" <?php echo ($cmbStatus) ? 'checked' : ''; ?>>
                        <span class="error"><?php echo form_error('txtStatus'); ?></span>
                    </td>
                </tr>
                <?php if ($id) { ?>
                    <tr>
                        <td align="right"><label><?php echo $lblDelete; ?> </label></td>
                        <td>
                            <input type="checkbox" name="txtDelete" class="txtDelete" value="1" <?php echo ($txtDelete) ? 'checked' : ''; ?>/>
                            <span class="error"><?php echo form_error('txtDelete'); ?>
                        </td>
                    </tr>
                <?php } ?>
                <tr>           
                    <td align="left" colspan="2">
                        <input type="submit" name="btnSubmit" value="<?php echo $submit; ?>" />
                    </td>
                </tr>                                                                                        
            </table> 
        </form>
    </div>
</div>
<!-- BEGIN dialog message -->
<div id="dialog" title="<?php echo $dialogTitle; ?>">
    <?php echo isset($message) ? $message : ''; ?>
</div>
<!-- END dialog message -->
<script type="text/javascript">
    $(document).ready(function() {
        $(function() {
            $(".datepicker").datepicker({
                dateFormat: 'yy/mm/dd',
                showOn: "button",
                buttonImage: "<?php echo base_url(); ?>/public/sites/images/calendaricon.gif",
                buttonImageOnly: true,
                changeMonth: true,
                changeYear: true,
                yearRange: '<?php echo $minYear . ':' . $maxYear; ?>'
            });
        });
<?php if (isset($flag) && $flag == TRUE): ?>
            $(function() {
                $("#dialog").dialog({
                    modal: true,
                    close: function() {
                        window.location.href = '<?php echo base_url('/employee'); ?>';
                    },
                    buttons: [{
                            text: '<?php echo $this->lang->line('MC019'); ?>',
                            click: function() {
                                window.location.href = '<?php echo base_url('/employee'); ?>';
                            }
                        }],
                });
            });
<?php elseif (isset($flag) && $flag == FALSE): ?>
            $(function() {
                $("#dialog").dialog({
                    buttons: [{
                            text: '<?php echo $this->lang->line('MC019'); ?>',
                            click: function() {
                                $("#dialog").dialog('close');
                            }
                        }]
                });
            });
<?php endif; ?>
    });
    /*when change employee type*/
    $('.cmbEmployeeType').change(function() {
        employeeTypeRequire();
    });
    /*when have value of EndOfficialDate */
    $('.txtEndOfficialDate').change(function(e) {
        employeeTypeRequire();
    });
    function employeeTypeRequire() {
        if ($('.cmbEmployeeType').val() == 1) {
            $('.StartOfficialDate font, .EndOfficialDate font').text('(*)');
        } else {
            $('.StartOfficialDate font, .EndOfficialDate font').text('');
        }
        if ($('.txtEndOfficialDate').val()) {
            $('.StartOfficialDate font').text('(*)');
        }
    }
    employeeTypeRequire();
</script>